package com.sandasai.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.sandasai.base.BaseDaoImpl;
import com.sandasai.dao.MarkDao;
import com.sandasai.domain.Mark;
@Repository("markDao")
public class MarkDaoImpl extends BaseDaoImpl<Mark> implements MarkDao {

	@Override
	public boolean contain(Mark mark){
		
		try {
			int workid = mark.getWork().getId();
			int teacherid = mark.getTeacher().getId();
			String queryString = "from Mark m where m.work.id="+ workid +" and m.teacher.id="+teacherid;
			Session session = this.getSession();
			Query q = session.createQuery(queryString);
			if(q.list().size() == 0)
				return false;
			return true;
		} catch (RuntimeException re) {
			
			throw re;
		}
	}
}
